#ifndef BitSet_First
#define BitSet_First
#ifdef __GNUG__
#pragma interface
#endif

//---- BitSet ------------------------------------------------------------------
//     a set of small integers

#include "Object.h"

class BitSet {
protected:
	u_long m;

	BitSet(const BitSet &)
		{ }
	BitSet(u_long i, double) // second parameter double is a trick
							// to overload BitSet(unsigned long i1);
		{ m= i; }
public:
	MetaDef(BitSet);

	BitSet()
		{ m= 0; }
	BitSet(int i1)
		{ m= BIT(i1); }
	BitSet(int i1, int i2)
		{ m= BIT(i1)|BIT(i2); }
	BitSet(int i1, int i2, int i3)
		{ m= BIT(i1)|BIT(i2)|BIT(i3); }
	BitSet(int i1, int i2, int i3, int i4)
		{ m= BIT(i1)|BIT(i2)|BIT(i3)|BIT(i4); }
	BitSet(int i1, int i2, int i3, int i4, int i5)
		{  m= BIT(i1)|BIT(i2)|BIT(i3)|BIT(i4)|BIT(i5); }
	BitSet(int i1, int i2, int i3, int i4, int i5, int i6)
		{ m= BIT(i1)|BIT(i2)|BIT(i3)|BIT(i4)|BIT(i5)|BIT(i6); }
	BitSet(int i1, int i2, int i3, int i4, int i5, int i6, int i7)
		{ m= BIT(i1)|BIT(i2)|BIT(i3)|BIT(i4)|BIT(i5)|BIT(i6)|BIT(i7); }
	BitSet(BitSet *n)
		{ m= n->m; }
		
	BitSet operator~()
		{ return BitSet(~m, 0.0); }
	BitSet operator-(BitSet n)
		{ return BitSet(m & ~n.m, 0.0); }
	bool operator>(BitSet n)
		{ return m == (m|n.m) && m != n.m; }
	bool operator<(BitSet n)
		{ return n.m == (m|n.m) && m != n.m; }
	bool operator>=(BitSet n)
		{ return m == (m|n.m); }
	bool operator<=(BitSet n)
		{ return n.m == (m|n.m); }
	bool operator==(BitSet n)
		{ return m == n.m; }
	bool operator!=(BitSet n)
		{ return m != n.m; }
	BitSet operator&(BitSet n)
		{ return BitSet(m & n.m, 0.0); }
	BitSet operator^(BitSet n)
		{ return BitSet(m ^ n.m, 0.0); }
	BitSet operator|(BitSet n)
		{ return BitSet(m | n.m, 0.0); }
	// void operator=(BitSet n)        { m = n.m; } // necessary???
	void operator-=(BitSet n)
		{ m &= ~n.m; }
	void operator&=(BitSet n)
		{ m &= n.m; }
	void operator^=(BitSet n)
		{ m ^= n.m; }
	void operator|=(BitSet n)
		{ m |= n.m; }
	int AsMask()
		{ return m; }
	bool Includes(int i)
		{ return (m & BIT(i)) != 0; }
	bool Contains(int i)
		{ return Includes(i); }
	unsigned long Hash();
	bool IsEmpty();
	OStream& PrintOn(OStream&);
	IStream& ReadFrom(IStream&);
	int Size();
	int Capacity();
};

//---- BitSetIter --------------------------------------------------------------

class BitSetIter {
	BitSet *cb;
	int pos;
public:
	BitSetIter(BitSet *s)
		{ cb=s; pos= 0; }
		
	void Reset(BitSet *);
	int operator()();
};

#endif
